package ws.very.util.cashbah

import com.mongodb.casbah.{ MongoCollection }
import com.mongodb.casbah.TypeImports

trait WithMongoCol {
  protected def collection: MongoCollection
  protected def col = collection
}

trait MongoCollExt {
  def coll: MongoCollection
  import MoShortType._
  import Imports._

  def byId[A](id: A) = new {

    def is = MO("_id" -> id)

    def update[B](o: B, upsert: Boolean = true, multi: Boolean = false, concern: WriteConcern = coll.writeConcern) //
    (implicit objView: B => TypeImports.DBObject, encoder: TypeImports.DBEncoder = coll.customEncoderFactory.map(_.create).orNull): TypeImports.WriteResult =
      coll.update(is, o, upsert, multi, concern)

  }
}

trait WithMongoDSL {

}
